﻿using AutoMapper;
using MediatR;
using S_Gridding.Api.Application.Commands.Cellgrid;
using S_Gridding.Api.Application.Commands.Gridding;
using S_Gridding.Domains.FoundGridding;
using S_Gridding.Infrastructure.Interface.IWrite;
using S_Userinfor.Domains;

namespace S_Gridding.Api.Application.CommandsHanders.CellgridHanders
{
    public class CellgridDelCommandsHanders : IRequestHandler<CellgridDelCommands, int>
    {
        private readonly ICellgridRepository _cellgrid;

        public CellgridDelCommandsHanders(ICellgridRepository cellgrid)
        {
            _cellgrid = cellgrid;
        }

        public async Task<int> Handle(CellgridDelCommands request, CancellationToken cancellationToken)
        {
            var res = await _cellgrid.GetFindAsync(request.Id);
            res.IsDel = true;
            return await _cellgrid.UpdateAsync(res);
        }
    }
}
